Skip to content

stdlib_system: essential path functionality #999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

wassup05
Copy link
Contributor

@wassup05 wassup05 commented Jun 7, 2025

A few path related functions for ease of future functionality have been added.

  • joinpath: joins the given paths according to the platform's path-separator.
  • operator(/): as was suggested in the Fortran discourse here an operator is also provided for the same functionality
  • splitpath: splits the path following the last path-separator and returns the head and tail.
  • basename: just returns the tail of splitpath
  • dirname: just returns the head of splitpath

The pathsep parameter contains either / or \ depending on the platform and is a compile-time constant now, so is the parameter, ISWIN

Do let me know your thoughts.

@sebastian-mutz
Copy link
Contributor

Thanks for the PR, @wassup05. Just a minor point (not related to functionality) about examples for now: It's always useful - esp. for those learning by examples - to have an idea of the expected output. Other stdlib examples add the expected print results as a comment below the respective commands. I would recommend to do the same here.

@wassup05
Copy link
Contributor Author

I will add that with the other reviews @sebastian-mutz, I don't want to trigger the ci/cd workflow just for a few comments. Also on a second thought maybe instead of the if (ISWIN) ... thing I could separate the two examples...

@jalvesz
Copy link
Contributor

jalvesz commented Jun 15, 2025

The issue with Ninja detecting a "circular dependency" (there was non) was related to the stdlib_system.F90 file not being visible in a correct manner in the CMakeLists.txt file.

The group:

# Preprocessed files to contain preprocessor directives -> .F90
set(cppFiles

corresponds to .fypp files for which the suffix should be changed to .F90. Not for already .F90 files.

Copy link
Contributor

@jalvesz jalvesz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @wassup05! Thanks for this nice work!!

@jalvesz jalvesz requested review from perazz, jvdp1 and Copilot June 15, 2025 18:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces essential path manipulation functions and related operator overloads to simplify path handling across platforms. Key changes include:

  • Implementation of joinpath (and its operator(/)) for concatenating paths.
  • Addition of splitpath and its derivatives (basename, dirname) for decomposing paths.
  • Updates to tests, examples, documentation, and build files to support and illustrate the new functionality.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/system/test_path.f90 Adds unit tests for new path functions and operator functionality.
test/system/CMakeLists.txt Registers the new "path" test.
src/stdlib_system_path.f90 Implements joinpath, operator(/), splitpath, basename, and dirname.
src/stdlib_system.F90 Defines interfaces and exports for the new path functionality.
src/CMakeLists.txt Includes the new path source file in the build.
example/system/*.f90 Provides usage examples for joinpath, splitpath, dirname, and basename.
doc/specs/stdlib_system.md Updates the spec documentation to incorporate the new interfaces.
config/fypp_deployment.py Passes the uppercase system name flag to the build commands.
CMakeLists.txt Adds compile options to define the system name macro.
Comments suppressed due to low confidence (2)

example/system/example_path_dirname.f90:2

  • The program name 'example_path_splitpath' does not match the file's purpose (dirname functionality). Consider renaming it to 'example_path_dirname'.
program example_path_splitpath

example/system/example_path_basename.f90:2

  • The program name 'example_path_splitpath' in this file appears to be a copy-paste error; it should reflect basename functionality (e.g., 'example_path_basename').
program example_path_splitpath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants